home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Surfer: Getting Started
/
Internet Surfer - Getting Started (Wayzata Technology)(7231)(1995).bin
/
pc
/
mac
/
bonus
/
peter_le
/
macbinar
/
mymemory.uni
< prev
next >
Wrap
Text File
|
1992-11-19
|
2KB
|
82 lines
unit MyMemory;
interface
{ These should really be changed to inlines }
procedure MDisposePtr (var p: univ ptr);
procedure MNewPtr (var p: univ ptr; size: longInt);
procedure MFillDisposePtr (var p: univ ptr);
procedure MFillNewPtr (var p: univ ptr; size: longInt);
procedure MFill (p: univ ptr; size: longInt; val: integer);
procedure MFillLong (p: univ ptr; size: longInt; val: longInt);
{ ptr and size must be long alligned }
implementation
const
fill_byte = $E5; { odd, big, negative, easily recognizable }
function CheckPtr (p: ptr): boolean;
begin
if p = nil then
DebugStr('Memory Error!');
CheckPtr := p <> nil;
end;
procedure MDisposePtr (var p: univ ptr);
begin
if CheckPtr(p) then begin
DisposPtr(p);
end;
p := nil;
end;
procedure MNewPtr (var p: univ ptr; size: longInt);
begin
p := NewPtr(size);
end;
procedure MFillDisposePtr (var p: univ ptr);
begin
if CheckPtr(p) then begin
MFill(p, GetPtrSize(p), fill_byte);
DisposPtr(p);
end;
p := nil;
end;
procedure MFillNewPtr (var p: univ ptr; size: longInt);
begin
p := NewPtr(size);
if p <> nil then
MFill(p, GetPtrSize(p), fill_byte);
end;
procedure MFill (p: univ ptr; size: longInt; val: integer);
var
i: longInt;
begin
if CheckPtr(p) then begin
for i := longInt(p) to longInt(p) + size - 1 do begin
ptr(i)^ := val;
end;
end;
end;
procedure MFillLong (p: univ ptr; size: longInt; val: longInt);
type
longPtr = ^longInt;
var
i: longInt;
begin
if CheckPtr(p) then begin
i := longInt(p);
while size > 3 do begin
longPtr(i)^ := val;
i := i + 4;
size := size - 4;
end;
end;
end;
end.